<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <title>畜禽普查移动端登录</title>
    <meta content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" name="viewport">
    <link href="static/wx/css/style.css" rel="stylesheet" type="text/css">

</head>
<body>
<!--头像-->
<div class="head">
    <div class="img">
        <img src="static/wx/picture/head.png" alt="头">
    </div>
</div>
<!--登陆-->
<form action="javascript:0;">
    <input id="openid" th:value="${openid}" type="hidden">
    <div class="item">
        <input autocomplete="off" class="name" id="username" maxlength="11" name="username" placeholder="请输入您的帐号"
               type="text">
    </div>
    <div class="item">
        <input autocomplete="off" class="password" id="password" name="password" placeholder="请输入您的密码"
               type="password">
    </div>
</form>
<div class="submit">
	<button id="login">登&nbsp;陆</button>
</div>
<!--尾部-->
<div class="footer">
    <img src="static/wx/picture/logo.png">
    <p>登录使用就表示同意用户协议<a href="javascript:;">条款</a>和<a href="javascript:;">隐私</a>政策</p>
</div>
</body>
<script src="/static/vendor/jquery/jquery-3.3.1.min.js"></script>
<script src="static/wx/js/flexible.js" type="text/javascript"></script>
<script src="static/wx/js/zepto.min.js" type="text/javascript"></script>
<script src="/static/vendor/skin/js/md5.js"></script>
<script type="text/javascript">
    // 提交验证
    $("#login").click(function () {
        var username = $('#username').val();
        var password = $('#password').val();
        if ($.trim(username) == '') {
            alert("请输入帐号")
            $('#username').focus()
            return false
        }
        if ($.trim(password) == '') {
            alert("请输入密码")
            $('#password').focus()
            return false
        }
        $.post('/login', {username: $.trim($("#username").val()), password: $.md5($.trim($("#password").val()))},
            function (value) {
                if (value.status !== 'SUCCESS') {
                    alert('用户名密码错误');
                } else {
                    $.get("/bingWx?openid=" + $("#openid").val(), function (res) {
                        if (res === 1) {
                            window.location.href = "/goIndex";
                        } else {
                            alert("账号异常")
                        }
                    })
                }

            }, "json");
    })
</script>
</html>
